home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / TBUTIL2.LZH / GETDATE.INC < prev    next >
Text File  |  1984-07-13  |  2KB  |  52 lines

  1.  
  2. PROCEDURE getdate(VAR year:INTEGER;
  3.                   VAR month,date,hour,min:BYTE);
  4.  
  5. TYPE
  6.    mday = ARRAY[1..12] OF BYTE;
  7. VAR
  8.    i,ndays: INTEGER;
  9. CONST
  10.    nday : mday = (31,28,31,30,31,30,31,31,30,31,30,31);
  11. BEGIN
  12.    BEGIN
  13.    INLINE
  14.     ( $b4/$2a/            {   mov ah,2a }
  15.       $cd/$21/            {   int 21h         dos interrupt  2a }
  16.       $1e/                {   push DS         save ds}
  17.       $85/$5e/$16/        {   mov ds,[bp+16]  load segment year}
  18.       $8b/$5e/$14/        {   mov bx,[bp+14]  load offset year}
  19.       $89/$0f/            {   mov [bx],cx     put cx into year}
  20.       $85/$5e/$12/        {   mov ds,[bp+12]  load segment month}
  21.       $8b/$5e/$10/        {   mov bx,[bp+10]  load offset month}
  22.       $88/$37/            {   mov [bx],dh     put dh into month}
  23.       $85/$5e/$0e/        {   mov ds,[bp+0e]  load segment date}
  24.       $8b/$5e/$0c/        {   mov bx,[bp+0c]  load offset date}
  25.       $88/$17/            {   mov [bx],dl     put al into date}
  26.  
  27.       $b4/$2c/            {   mov ah,2c}
  28.       $cd/$21/            {   int 21h         dos interrupt  2c }
  29.       $85/$5e/$0a/        {   mov ds,[bp+0a]  load segment hour}
  30.       $8b/$5e/$08/        {   mov bx,[bp+08]  load offset hour}
  31.       $88/$2f/            {   mov [bx],ch     put dh into hour}
  32.       $85/$5e/$06/        {   mov ds,[bp+06]  load segment min}
  33.       $8b/$5e/$04/        {   mov bx,[bp+04]  load offset min}
  34.       $88/$0f/            {   mov [bx],cl     put al into min}
  35.       $1f                 {   pop DS          restore ds}
  36.        )
  37.    END;
  38.  
  39. { get day of week }
  40.  
  41. {   ndays:=date;
  42.    for i:=1 to month-1 do
  43.       ndays:=ndays+nday[i];
  44.    if (month >= 3) then if (year mod 4 = 0 ) then
  45.    if ((year mod 100 <>0)  or (year mod 400 =0))  then ndays := ndays+1;
  46.    ndays:=ndays+trunc(365.25*(year-1901));
  47.    day:=(  (ndays+2)  mod 7 ) + 1;
  48. }
  49. {   writeln('Date is ',year,month:4,date:4,hour:5,':',min:2,day:7);}
  50.    year:=year  { -1900  } ;
  51. END;
  52.